FROM golang:1.14.1-alpine3.11 as builder

RUN sed -i.bak 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
    apk update \
    && apk --no-cache add \
    make \
    tree && \
    mkdir -p /code/

WORKDIR /code
COPY main.go /code

RUN export GOPROXY=https://goproxy.cn && \
    make go-build

FROM alpine:3.11 as prod

LABEL Maintainer="madongsheng@moego.com" \
      Description="Jmeter based on Alpine Linux."

RUN sed -i.bak 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
    apk update \
    && apk --no-cache add \
    make \
    tree && \
    mkdir -p /go/

COPY --from=builder /code/main /go/

# setup Shanghai timezone
ENV TZ=Asia/Shanghai

EXPOSE 8090

WORKDIR /go

ENTRYPOINT ["./server"]